package com.yidu.t299.service.fxj.impl;

import com.yidu.t299.dao.fxj.SyllabussMapper;
import com.yidu.t299.domain.fxj.*;
import com.yidu.t299.service.fxj.SyllabussBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
@Service
@Transactional
public class SyllabussBizImpl implements SyllabussBiz {
    @Autowired
    public SyllabussMapper syllabusMapper;

    //查找教室
    @Override
    public List<ClassRoom> classroom() {
        List<ClassRoom> list = syllabusMapper.classroom();
        return list;
    }

    //查找班级
    @Override
    public List<ClassS> classSelect() {
        List<ClassS> classList = syllabusMapper.classSelect();
        return classList;
    }

    //查找老师
    @Override
    public List<Record> teacher() {

        List<Record> teacher = syllabusMapper.teacher();
        return teacher;
    }

    //查找科目
    @Override
    public List<LessonDomain> lesson() {
        List<LessonDomain> lesson = syllabusMapper.lesson();
        return lesson;
    }

    //新增到syllabus表
    @Override
    public Integer insert(Syllabus syllabus) {
        return syllabusMapper.insert(syllabus);
    }


    //得到syllabusId列的最大id值
    @Override
    public int syllabusIdMax() {
        return syllabusMapper.syllabusIdMax();
    }


    //返回一周的课程表
    @Override
    public List<SyllabusP> select() {
        List<SyllabusP> list = new ArrayList<>();
        //当前一周 周几有课
        String[] weekName = syllabusMapper.selectWeekName();
        //实现课程表数据
        for (int i = 0; i < weekName.length ; i++) {
            //当前星期n的课程
            List<SyllabusP> syllabusPList= syllabusMapper.select(weekName[i]);
            //将课程一条一条放入 list集合
            for (SyllabusP syllabusP : syllabusPList){
                list.add(syllabusP);
            }
        }
        return list;
    }
}
